package pe.gob.sunarp.publicidad.repositorio;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import pe.gob.sunarp.entidad.OficRegistral;
import pe.gob.sunarp.entidad.RegisPublico;
import pe.gob.sunarp.entidad.TmAreaRegistral;
import pe.gob.sunarp.publicidad.beanconsulta.BeanTest;

@Repository("solicitudRepositorio")
public class HibernateSolicitudRepositorio implements SolicitudRepositorio {
	private static Logger log = Logger
			.getLogger(HibernateTituloRepositorio.class.getName());

	private SessionFactory sessionFactory;

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	private JdbcTemplate jdbcTemplate;

	@Autowired
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public List<RegisPublico> listaOficinaReg() {

		Session session = sessionFactory.getCurrentSession();
		List<RegisPublico> lista = session.createQuery(
				"from RegisPublico").list();
		return lista;
	}
	
	public List<BeanTest> findTest(){
		 
		String sql = "SELECT * FROM TM_AREA_REGISTRAL";
	 
		List<BeanTest> test  = getJdbcTemplate().query(sql,
				new BeanPropertyRowMapper(BeanTest.class));
	 
		return test;
	}
	
	

}
